package com.example.hxd.zndzg.activity;


import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.example.hxd.zndzg.R;
import com.example.hxd.zndzg.view.MetaballView;


/**
 * Created by Administrator on 2018/6/2.
 */

//设置闪屏效果

public class StartActivity extends AppCompatActivity {
    private MetaballView metaballView;//自定义的小球加载布局
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        metaballView = (MetaballView) this.findViewById(R.id.meta_ball);
        metaballView.setPaintMode(1);



        /**
         * 延迟三秒显示小圆球
         */
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                metaballView.setVisibility(View.VISIBLE);
            }
        }, 1000);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                toMainActivity();   //执行跳转下一个界面的方法
            }
        }, 4000);
    }

    /**
     * 跳转到下一个界面
     * */
    public void toMainActivity() {
        Intent intent = new Intent(this, HomeActivity.class);  //跳转到主界面
        startActivity(intent);  //开始跳转
        finish();   //finish当前界面
    }
}
